﻿using System.Collections.Generic;
using System.Linq;
using yiCommerce.Core.Domain.ShoppingCarts;
using yiCommerce.Core.Helper;

namespace yiCommerce.Service.Products
{
    public class ProductVariantAttributeFormatter:IProductVariantAttributeFormatter
    {
        public string ToFormattedString(string attributeXml)
        {
            var xmlList = JsonHelper.ToObject<IList<ProductVariantAttributeValueXml>>(attributeXml);

            return string.Join(" ", xmlList.Select(c => c.AttributeName + ":" + c.AttributeValue).ToList());
        }
    }
}